home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 September / PCWorld_2007-09_cd.bin / komunikace / firefox / Firefox Setup 2.0.0.6.exe / nonlocalized / components / FeedConverter.js < prev    next >
Encoding:
Text File  |  2007-07-25  |  20.3 KB  |  611 lines

  1. //@line 38 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/FeedConverter.js"
  2.  
  3. const Cc = Components.classes;
  4. const Ci = Components.interfaces;
  5. const Cr = Components.results;
  6.  
  7. function LOG(str) {
  8.   dump("*** " + str + "\n");
  9. }
  10.  
  11. const FC_CLASSID = Components.ID("{229fa115-9412-4d32-baf3-2fc407f76fb1}");
  12. const FC_CLASSNAME = "Feed Stream Converter";
  13. const FS_CLASSID = Components.ID("{2376201c-bbc6-472f-9b62-7548040a61c6}");
  14. const FS_CLASSNAME = "Feed Result Service";
  15. const FS_CONTRACTID = "@mozilla.org/browser/feeds/result-service;1";
  16. const FPH_CONTRACTID = "@mozilla.org/network/protocol;1?name=feed";
  17. const FPH_CLASSID = Components.ID("{4f91ef2e-57ba-472e-ab7a-b4999e42d6c0}");
  18. const FPH_CLASSNAME = "Feed Protocol Handler";
  19. const PCPH_CONTRACTID = "@mozilla.org/network/protocol;1?name=pcast";
  20. const PCPH_CLASSID = Components.ID("{1c31ed79-accd-4b94-b517-06e0c81999d5}");
  21. const PCPH_CLASSNAME = "Podcast Protocol Handler";
  22. const FHS_CONTRACTID = "@mozilla.org/browser/feeds/handler-service;1";
  23. const FHS_CLASSID = Components.ID("{792a7e82-06a0-437c-af63-b2d12e808acc}");
  24. const FHS_CLASSNAME = "Feed Handler Service";
  25.  
  26. const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
  27. const TYPE_ANY = "*/*";
  28.  
  29. const FEEDHANDLER_URI = "about:feeds";
  30.  
  31. const PREF_SELECTED_APP = "browser.feeds.handlers.application";
  32. const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice";
  33. const PREF_SELECTED_ACTION = "browser.feeds.handler";
  34. const PREF_SELECTED_READER = "browser.feeds.handler.default";
  35.  
  36. function safeGetBoolPref(pref, defaultValue) {
  37.   var prefs =   
  38.       Cc["@mozilla.org/preferences-service;1"].
  39.       getService(Ci.nsIPrefBranch);
  40.   try {
  41.     return prefs.getBoolPref(pref);
  42.   }
  43.   catch (e) {
  44.   }
  45.   return defaultValue;
  46. }
  47.  
  48. function safeGetCharPref(pref, defaultValue) {
  49.   var prefs =   
  50.       Cc["@mozilla.org/preferences-service;1"].
  51.       getService(Ci.nsIPrefBranch);
  52.   try {
  53.     return prefs.getCharPref(pref);
  54.   }
  55.   catch (e) {
  56.   }
  57.   return defaultValue;
  58. }
  59.  
  60. function FeedConverter() {
  61. }
  62. FeedConverter.prototype = {
  63.   /**
  64.    * This is the downloaded text data for the feed.
  65.    */
  66.   _data: null,
  67.   
  68.   /**
  69.    * This is the object listening to the conversion, which is ultimately the
  70.    * docshell for the load.
  71.    */
  72.   _listener: null,
  73.  
  74.   /**
  75.    * Records if the feed was sniffed
  76.    */
  77.   _sniffed: false,
  78.   
  79.   /**
  80.    * See nsIStreamConverter.idl
  81.    */
  82.   canConvert: function FC_canConvert(sourceType, destinationType) {
  83.     // We only support one conversion.
  84.     return destinationType == TYPE_ANY && sourceType == TYPE_MAYBE_FEED;
  85.   },
  86.   
  87.   /**
  88.    * See nsIStreamConverter.idl
  89.    */
  90.   convert: function FC_convert(sourceStream, sourceType, destinationType, 
  91.                                context) {
  92.     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  93.   },
  94.   
  95.   /**
  96.    * See nsIStreamConverter.idl
  97.    */
  98.   asyncConvertData: function FC_asyncConvertData(sourceType, destinationType,
  99.                                                  listener, context) {
  100.     this._listener = listener;
  101.   },
  102.   
  103.   /**
  104.    * Whether or not the preview page is being forced.
  105.    */
  106.   _forcePreviewPage: false,
  107.  
  108.   /** 
  109.    * Release our references to various things once we're done using them.
  110.    */
  111.   _releaseHandles: function FC__releaseHandles() {
  112.     this._listener = null;
  113.     this._request = null;
  114.   },
  115.  
  116.   /**
  117.    * See nsIFeedResultListener.idl
  118.    */
  119.   handleResult: function FC_handleResult(result) {
  120.     // Feeds come in various content types, which our feed sniffer coerces to
  121.     // the maybe.feed type. However, feeds are used as a transport for 
  122.     // different data types, e.g. news/blogs (traditional feed), video/audio
  123.     // (podcasts) and photos (photocasts, photostreams). Each of these is 
  124.     // different in that there's a different class of application suitable for
  125.     // handling feeds of that type, but without a content-type differentiation
  126.     // it is difficult for us to disambiguate.
  127.     // 
  128.     // The other problem is that if the user specifies an auto-action handler
  129.     // for one feed application, the fact that the content type is shared means 
  130.     // that all other applications will auto-load with that handler too, 
  131.     // regardless of the content-type. 
  132.     //
  133.     // This means that content-type alone is not enough to determine whether
  134.     // or not a feed should be auto-handled. This means that for feeds we need
  135.     // to always use this stream converter, even when an auto-action is 
  136.     // specified, not the basic one provided by WebContentConverter. This 
  137.     // converter needs to consume all of the data and parse it, and based on
  138.     // that determination make a judgement about type. 
  139.     //
  140.     // Since there are no content types for this content, and I'm not going to
  141.     // invent any, the upshot is that while a user can set an auto-handler for
  142.     // generic feed content, the system will prevent them from setting an auto-
  143.     // handler for other stream types. In those cases, the user will always see
  144.     // the preview page and have to select a handler. We can guess and show 
  145.     // a client handler, but will not be able to show web handlers for those
  146.     // types.
  147.     //
  148.     // If this is just a feed, not some kind of specialized application, then
  149.     // auto-handlers can be set and we should obey them. 
  150.     try {
  151.       var feedService = 
  152.           Cc["@mozilla.org/browser/feeds/result-service;1"].
  153.           getService(Ci.nsIFeedResultService);
  154.       if (!this._forcePreviewPage && result.doc) {
  155.         var handler = safeGetCharPref(PREF_SELECTED_ACTION, "ask");
  156.         if (handler != "ask") {
  157.           if (handler == "reader")
  158.             handler = safeGetCharPref(PREF_SELECTED_READER, "bookmarks");
  159.           switch (handler) {
  160.             case "web":
  161.               var wccr = 
  162.                   Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
  163.                   getService(Ci.nsIWebContentConverterService);
  164.               var feed = result.doc.QueryInterface(Ci.nsIFeed);
  165.               if (feed.type == Ci.nsIFeed.TYPE_FEED &&
  166.                   wccr.getAutoHandler(TYPE_MAYBE_FEED)) {
  167.                 wccr.loadPreferredHandler(this._request);
  168.                 return;
  169.               }
  170.               break;
  171.  
  172.             default:
  173.               LOG("unexpected handler: " + handler);
  174.               // fall through -- let feed service handle error
  175.             case "bookmarks":
  176.             case "client":
  177.               try {
  178.                 var feed = result.doc.QueryInterface(Ci.nsIFeed);
  179.                 var title = feed.title ? feed.title.plainText() : "";
  180.                 var desc = feed.subtitle ? feed.subtitle.plainText() : "";
  181.                 feedService.addToClientReader(result.uri.spec, title, desc);
  182.                 return;
  183.               }
  184.               catch(ex) { /* fallback to preview mode */ }
  185.           }
  186.         }
  187.       }
  188.  
  189.       var ios = 
  190.            Cc["@mozilla.org/network/io-service;1"].
  191.            getService(Ci.nsIIOService);
  192.       var chromeChannel;
  193.  
  194.       // show the feed page if it wasn't sniffed and we have a document,
  195.       // or we have a document, title, and link or id
  196.       if (result.doc && (!this._sniffed ||
  197.           (result.doc.title && (result.doc.link || result.doc.id)))) {
  198.         // If there was no automatic handler, or this was a podcast,
  199.         // photostream or some other kind of application, we must always
  200.         // show the preview page...
  201.  
  202.         // Store the result in the result service so that the display page can 
  203.         // access it.
  204.         feedService.addFeedResult(result);
  205.         
  206.         // Now load the actual XUL document.
  207.         var chromeURI = ios.newURI(FEEDHANDLER_URI, null, null);
  208.         chromeChannel = ios.newChannelFromURI(chromeURI, null);
  209.         chromeChannel.originalURI = result.uri;
  210.       }
  211.       else
  212.         chromeChannel = ios.newChannelFromURI(result.uri, null);
  213.  
  214.       chromeChannel.loadGroup = this._request.loadGroup;
  215.       chromeChannel.asyncOpen(this._listener, null);
  216.     }
  217.     finally {
  218.       this._releaseHandles();
  219.     }
  220.   },
  221.   
  222.   /**
  223.    * See nsIStreamListener.idl
  224.    */
  225.   onDataAvailable: function FC_onDataAvailable(request, context, inputStream, 
  226.                                                sourceOffset, count) {
  227.     this._processor.onDataAvailable(request, context, inputStream,
  228.                                     sourceOffset, count);
  229.   },
  230.   
  231.   /**
  232.    * See nsIRequestObserver.idl
  233.    */
  234.   onStartRequest: function FC_onStartRequest(request, context) {
  235.     var channel = request.QueryInterface(Ci.nsIChannel);
  236.  
  237.     // Check for a header that tells us there was no sniffing
  238.     // The value doesn't matter.
  239.     try {
  240.       var httpChannel = channel.QueryInterface(Ci.nsIHttpChannel);
  241.       var noSniff = httpChannel.getResponseHeader("X-Moz-Is-Feed");
  242.     }
  243.     catch (ex) {
  244.       this._sniffed = true;
  245.     }
  246.  
  247.     this._request = request;
  248.     
  249.     // Save and reset the forced state bit early, in case there's some kind of
  250.     // error.
  251.     var feedService = 
  252.         Cc["@mozilla.org/browser/feeds/result-service;1"].
  253.         getService(Ci.nsIFeedResultService);
  254.     this._forcePreviewPage = feedService.forcePreviewPage;
  255.     feedService.forcePreviewPage = false;
  256.  
  257.     // Parse feed data as it comes in
  258.     this._processor =
  259.         Cc["@mozilla.org/feed-processor;1"].
  260.         createInstance(Ci.nsIFeedProcessor);
  261.     this._processor.listener = this;
  262.     this._processor.parseAsync(null, channel.URI);
  263.     
  264.     this._processor.onStartRequest(request, context);
  265.   },
  266.   
  267.   /**
  268.    * See nsIRequestObserver.idl
  269.    */
  270.   onStopRequest: function FC_onStopReqeust(request, context, status) {
  271.     this._processor.onStopRequest(request, context, status);
  272.   },
  273.   
  274.   /**
  275.    * See nsISupports.idl
  276.    */
  277.   QueryInterface: function FC_QueryInterface(iid) {
  278.     if (iid.equals(Ci.nsIFeedResultListener) ||
  279.         iid.equals(Ci.nsIStreamConverter) ||
  280.         iid.equals(Ci.nsIStreamListener) ||
  281.         iid.equals(Ci.nsIRequestObserver)||
  282.         iid.equals(Ci.nsISupports))
  283.       return this;
  284.     throw Cr.NS_ERROR_NO_INTERFACE;
  285.   },
  286. };
  287.  
  288. var FeedConverterFactory = {
  289.   createInstance: function FS_createInstance(outer, iid) {
  290.     if (outer != null)
  291.       throw Cr.NS_ERROR_NO_AGGREGATION;
  292.     return new FeedConverter().QueryInterface(iid);
  293.   },
  294.  
  295.   QueryInterface: function FS_QueryInterface(iid) {
  296.     if (iid.equals(Ci.nsIFactory) ||
  297.         iid.equals(Ci.nsISupports))
  298.       return this;
  299.     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  300.   },
  301. };
  302.  
  303. /**
  304.  * Keeps parsed FeedResults around for use elsewhere in the UI after the stream
  305.  * converter completes. 
  306.  */
  307. var FeedResultService = {
  308.   
  309.   /**
  310.    * A URI spec -> [nsIFeedResult] hash. We have to keep a list as the
  311.    * value in case the same URI is requested concurrently.
  312.    */
  313.   _results: { },
  314.   
  315.   /**
  316.    * See nsIFeedService.idl
  317.    */
  318.   forcePreviewPage: false,
  319.   
  320.   /**
  321.    * See nsIFeedService.idl
  322.    */
  323.   addToClientReader: function FRS_addToClientReader(spec, title, subtitle) {
  324.     var prefs =   
  325.         Cc["@mozilla.org/preferences-service;1"].
  326.         getService(Ci.nsIPrefBranch);
  327.  
  328.     var handler = safeGetCharPref(PREF_SELECTED_ACTION, "bookmarks");
  329.     if (handler == "ask" || handler == "reader")                                
  330.       handler = safeGetCharPref(PREF_SELECTED_READER, "bookmarks");             
  331.  
  332.     switch (handler) {
  333.     case "client":
  334.       var clientApp = 
  335.         prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
  336. //@line 393 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/FeedConverter.js"
  337.       var ss = 
  338.           Cc["@mozilla.org/browser/shell-service;1"].
  339.           getService(Ci.nsIShellService_MOZILLA_1_8_BRANCH);
  340.       ss.openApplicationWithURI(clientApp, spec);
  341.       break;
  342.  
  343.     default:
  344.       // "web" should have been handled elsewhere
  345.       LOG("unexpected handler: " + handler);
  346.       // fall through
  347.     case "bookmarks":
  348.       var wm = 
  349.           Cc["@mozilla.org/appshell/window-mediator;1"].
  350.           getService(Ci.nsIWindowMediator);
  351.       var topWindow = wm.getMostRecentWindow("navigator:browser");
  352. //@line 411 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/FeedConverter.js"
  353.       topWindow.FeedHandler.addLiveBookmark(spec, title, subtitle);
  354. //@line 413 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/FeedConverter.js"
  355.       break;
  356.     }
  357.   },
  358.   
  359.   /**
  360.    * See nsIFeedService.idl
  361.    */
  362.   addFeedResult: function FRS_addFeedResult(feedResult) {
  363.     NS_ASSERT(feedResult.uri != null, "null URI!");
  364.     NS_ASSERT(feedResult.uri != null, "null feedResult!");
  365.     var spec = feedResult.uri.spec;
  366.     if(!this._results[spec])  
  367.       this._results[spec] = [];
  368.     this._results[spec].push(feedResult);
  369.   },
  370.   
  371.   /**
  372.    * See nsIFeedService.idl
  373.    */
  374.   getFeedResult: function RFS_getFeedResult(uri) {
  375.     NS_ASSERT(uri != null, "null URI!");
  376.     var resultList = this._results[uri.spec];
  377.     for (var i in resultList) {
  378.       if (resultList[i].uri == uri)
  379.         return resultList[i];
  380.     }
  381.     return null;
  382.   },
  383.   
  384.   /**
  385.    * See nsIFeedService.idl
  386.    */
  387.   removeFeedResult: function FRS_removeFeedResult(uri) {
  388.     NS_ASSERT(uri != null, "null URI!");
  389.     var resultList = this._results[uri.spec];
  390.     if (!resultList)
  391.       return;
  392.     var deletions = 0;
  393.     for (var i = 0; i < resultList.length; ++i) {
  394.       if (resultList[i].uri == uri) {
  395.         delete resultList[i];
  396.         ++deletions;
  397.       }
  398.     }
  399.     
  400.     // send the holes to the end
  401.     resultList.sort();
  402.     // and trim the list
  403.     resultList.splice(resultList.length - deletions, deletions);
  404.     if (resultList.length == 0)
  405.       delete this._results[uri.spec];
  406.   },
  407.  
  408.   createInstance: function FRS_createInstance(outer, iid) {
  409.     if (outer != null)
  410.       throw Cr.NS_ERROR_NO_AGGREGATION;
  411.     return this.QueryInterface(iid);
  412.   },
  413.   
  414.   QueryInterface: function FRS_QueryInterface(iid) {
  415.     if (iid.equals(Ci.nsIFeedResultService) ||
  416.         iid.equals(Ci.nsIFactory) ||
  417.         iid.equals(Ci.nsISupports))
  418.       return this;
  419.     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  420.   },
  421. };
  422.  
  423. /**
  424.  * A protocol handler that converts the URIs of Apple's various bogo protocol
  425.  * schemes into http, as they should be. Mostly, this object just forwards 
  426.  * things through to the HTTP protocol handler.
  427.  */
  428. function FeedProtocolHandler(scheme) {
  429.   this._scheme = scheme;
  430.   var ios = 
  431.       Cc["@mozilla.org/network/io-service;1"].
  432.       getService(Ci.nsIIOService);
  433.   this._http = ios.getProtocolHandler("http");
  434. }
  435. FeedProtocolHandler.prototype = {
  436.   _scheme: "",
  437.   get scheme() {
  438.     return this._scheme;
  439.   },
  440.   
  441.   get protocolFlags() {
  442.     return this._http.protocolFlags;
  443.   },
  444.   
  445.   get defaultPort() {
  446.     return this._http.defaultPort;
  447.   },
  448.   
  449.   allowPort: function FPH_allowPort(port, scheme) {
  450.     return this._http.allowPort(port, scheme);
  451.   },
  452.   
  453.   newURI: function FPH_newURI(spec, originalCharset, baseURI) {
  454.     var uri = 
  455.         Cc["@mozilla.org/network/standard-url;1"].
  456.         createInstance(Ci.nsIStandardURL);
  457.     uri.init(Ci.nsIStandardURL.URLTYPE_STANDARD, 80, spec, originalCharset,
  458.              baseURI);
  459.     return uri;
  460.   },
  461.   
  462.   newChannel: function FPH_newChannel(uri) {
  463.     var ios = 
  464.         Cc["@mozilla.org/network/io-service;1"].
  465.         getService(Ci.nsIIOService);
  466.     // feed: URIs either start feed://, in which case the real scheme is http:
  467.     // or feed:http(s)://, (which by now we've changed to feed://realscheme//)
  468.     const httpsChunk = "feed://https//";
  469.     const httpChunk = "feed://http//";
  470.     if (uri.spec.substr(0, httpsChunk.length) == httpsChunk)
  471.       uri.spec = "https://" + uri.spec.substr(httpsChunk.length);
  472.     else if (uri.spec.substr(0, httpChunk.length) == httpChunk)
  473.       uri.spec = "http://" + uri.spec.substr(httpChunk.length);
  474.     else
  475.       uri.scheme = "http";
  476.  
  477.     var channel =
  478.       ios.newChannelFromURI(uri, null).QueryInterface(Ci.nsIHttpChannel);
  479.     // Set this so we know this is supposed to be a feed
  480.     channel.setRequestHeader("X-Moz-Is-Feed", "1", false);
  481.     channel.originalURI = uri;
  482.     return channel;
  483.   },
  484.   
  485.   QueryInterface: function FPH_QueryInterface(iid) {
  486.     if (iid.equals(Ci.nsIProtocolHandler) ||
  487.         iid.equals(Ci.nsISupports))
  488.       return this;
  489.     throw Cr.NS_ERROR_NO_INTERFACE;
  490.   }  
  491. };
  492.  
  493. var Module = {
  494.   QueryInterface: function M_QueryInterface(iid) {
  495.     if (iid.equals(Ci.nsIModule) ||
  496.         iid.equals(Ci.nsISupports))
  497.       return this;
  498.     throw Cr.NS_ERROR_NO_INTERFACE;
  499.   },
  500.   
  501.   getClassObject: function M_getClassObject(cm, cid, iid) {
  502.     if (!iid.equals(Ci.nsIFactory))
  503.       throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  504.     
  505.     if (cid.equals(FS_CLASSID))
  506.       return FeedResultService;
  507.     if (cid.equals(FPH_CLASSID))
  508.       return new GenericComponentFactory(FeedProtocolHandler, "feed");
  509.     if (cid.equals(PCPH_CLASSID))
  510.       return new GenericComponentFactory(FeedProtocolHandler, "pcast");
  511.     if (cid.equals(FC_CLASSID))
  512.       return new GenericComponentFactory(FeedConverter);
  513.       
  514.     throw Cr.NS_ERROR_NO_INTERFACE;
  515.   },
  516.   
  517.   registerSelf: function M_registerSelf(cm, file, location, type) {
  518.     var cr = cm.QueryInterface(Ci.nsIComponentRegistrar);
  519.     
  520.     cr.registerFactoryLocation(FS_CLASSID, FS_CLASSNAME, FS_CONTRACTID,
  521.                                file, location, type);
  522.     cr.registerFactoryLocation(FPH_CLASSID, FPH_CLASSNAME, FPH_CONTRACTID,
  523.                                file, location, type);
  524.     cr.registerFactoryLocation(PCPH_CLASSID, PCPH_CLASSNAME, PCPH_CONTRACTID,
  525.                                file, location, type);
  526.  
  527.     // The feed converter is always attached, since parsing must be done to 
  528.     // determine whether or not auto-handling can occur. 
  529.     const converterPrefix = "@mozilla.org/streamconv;1?from=";
  530.     var converterContractID = 
  531.         converterPrefix + TYPE_MAYBE_FEED + "&to=" + TYPE_ANY;
  532.     cr.registerFactoryLocation(FC_CLASSID, FC_CLASSNAME, converterContractID,
  533.                                file, location, type);
  534.   },
  535.   
  536.   unregisterSelf: function M_unregisterSelf(cm, location, type) {
  537.     var cr = cm.QueryInterface(Ci.nsIComponentRegistrar);
  538.     cr.unregisterFactoryLocation(FPH_CLASSID, location);
  539.     cr.unregisterFactoryLocation(PCPH_CLASSID, location);
  540.   },
  541.   
  542.   canUnload: function M_canUnload(cm) {
  543.     return true;
  544.   }
  545. };
  546.  
  547. function NSGetModule(cm, file) {
  548.   return Module;
  549. }
  550.  
  551. //@line 44 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/../../../../toolkit/content/debug.js"
  552.  
  553. var gTraceOnAssert = true;
  554.  
  555. /**
  556.  * This function provides a simple assertion function for JavaScript.
  557.  * If the condition is true, this function will do nothing.  If the
  558.  * condition is false, then the message will be printed to the console
  559.  * and an alert will appear showing a stack trace, so that the (alpha
  560.  * or nightly) user can file a bug containing it.  For future enhancements, 
  561.  * see bugs 330077 and 330078.
  562.  *
  563.  * To suppress the dialogs, you can run with the environment variable
  564.  * XUL_ASSERT_PROMPT set to 0 (if unset, this defaults to 1).
  565.  *
  566.  * @param condition represents the condition that we're asserting to be
  567.  *                  true when we call this function--should be
  568.  *                  something that can be evaluated as a boolean.
  569.  * @param message   a string to be displayed upon failure of the assertion
  570.  */
  571.  
  572. function NS_ASSERT(condition, message) {
  573.   if (condition)
  574.     return;
  575.  
  576.   var assertionText = "ASSERT: " + message + "\n";
  577.  
  578. //@line 72 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/../../../../toolkit/content/debug.js"
  579.   Components.util.reportError(assertionText);
  580.   return;
  581. //@line 108 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/../../../../toolkit/content/debug.js"
  582. }
  583. //@line 37 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/GenericFactory.js"
  584.  
  585. /**
  586.  * An object implementing nsIFactory that can construct other objects upon
  587.  * createInstance, passing a set of parameters to that object's constructor.
  588.  */
  589. function GenericComponentFactory(ctor, params) {
  590.   this._ctor = ctor;
  591.   this._params = params;
  592. }
  593. GenericComponentFactory.prototype = {
  594.   _ctor: null,
  595.   _params: null,
  596.   
  597.   createInstance: function GCF_createInstance(outer, iid) {
  598.     if (outer != null)
  599.       throw Cr.NS_ERROR_NO_AGGREGATION;
  600.     return (new this._ctor(this._params)).QueryInterface(iid);
  601.   },
  602.   
  603.   QueryInterface: function GCF_QueryInterface(iid) {
  604.     if (iid.equals(Ci.nsIFactory) ||
  605.         iid.equals(Ci.nsISupports)) 
  606.       return this;
  607.     throw Cr.NS_ERROR_NO_INTERFACE;
  608.   }
  609. };
  610.  
  611.